home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-04-16 | 9.1 KB | 281 lines | [TEXT/MPCC] |
- /*
- File: QTInternals.c
-
- Contains: Functions dealing with dumping internal movie information.
-
- Written by: DTS
-
- Copyright: © 1995 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- <1> 1/4/95 khs first file
-
- */
-
-
- // INCLUDES
- #include "QTInternals.h"
- #include "DTSQTUtilities.h"
-
-
- // ______________________________________________________________________
- // FUNCTIONS
-
- // ______________________________________________________________________
- void ShowMovieTrackInfo(Movie theMovie)
- {
- long aTrackCount, index;
- Track aTrack;
- long aTrackUsage;
- OSErr anErr = noErr;
- Str255 tmpStr;
- Fixed height, width;
- short trackVol;
- MatrixRecord mr;
-
-
- GetWTitle(FrontWindow(), tmpStr);
- printf("\nTrack Information for %s:\n", p2cstr(tmpStr));
-
- // TRACK COUNT
- aTrackCount = GetMovieTrackCount(theMovie);
- anErr = GetMoviesError(); DebugAssert(anErr == noErr);
- if(anErr != noErr) return;
-
- if(aTrackCount == 0)
- {
- printf("The Movie has no tracks.\n");
- return;
- }
- else
- printf("The Movie has %d tracks.\n", aTrackCount);
-
- // Parse through each track and get more information:
- for(index = 1; index <= aTrackCount; index++)
- {
- OSType aTrackType;
- Media aMedia;
-
- printf("\n");
-
- aTrack = GetMovieIndTrack(theMovie, index);
-
- // TRACK TYPE
- aMedia = GetTrackMedia(aTrack);
- GetMediaHandlerDescription(aMedia, &aTrackType, 0, 0);
-
- switch (aTrackType)
- {
- case SoundMediaType: printf("This is a sound track.\n"); break;
- case VideoMediaType: printf("This is a video track.\n"); break;
- case TextMediaType: printf("This is a text track.\n"); break;
- case MPEGMediaType: printf("This is an MPEG track.\n"); break;
- case MusicMediaType: printf("This is a music track.\n"); break;
- case TimeCodeMediaType: printf("This is a time code track.\n"); break;
- default:
- {
- Byte *bp = (Byte *)&aTrackType;
- printf("The track is of type '%c%c%c%c' format.\n", bp[0], bp[1], bp[2], bp[3]);
- break;
- }
- }
-
- // TRACK ID
- printf("Track ID: %d\n", GetTrackID(aTrack));
-
- // TRACK ENABLED
- if(GetTrackEnabled(aTrack))
- printf("Track is enabled.\n");
- else
- printf("Track is disabled.\n");
-
- // TRACK LAYER
- printf("Track Layer: %d\n", GetTrackLayer(aTrack));
-
- // TRACK USAGE
- aTrackUsage = GetTrackUsage(aTrack);
- if(aTrackUsage & trackUsageInMovie)
- printf("Track is used in Movie.\n");
- if(aTrackUsage & trackUsageInPreview)
- printf("Track is used in a preview.\n");
- if(aTrackUsage & trackUsageInPoster)
- printf("Track is used in a poster.\n");
-
- // TRACK DURATION
- printf("Duration of the track = %ld\n", GetTrackDuration(aTrack));
-
- // TRACK DIMENSIONS
- GetTrackDimensions(aTrack, &width, &height);
- printf("Track width = %ld, Track height = %ld\n", Fix2Long(width), Fix2Long(height));
-
- // TRACK MATRIX
- GetTrackMatrix(aTrack, &mr);
-
- printf("Matrix record, row 0 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[0,0]),
- Fix2Long(*mr.matrix[0,1]), Fix2Long(*mr.matrix[0,2]));
- printf("Matrix record, row 1 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[1,0]),
- Fix2Long(*mr.matrix[1,1]), Fix2Long(*mr.matrix[1,2]));
- printf("Matrix record, row 2 = [%ld], [%ld], [%ld]\n", Fix2Long(*mr.matrix[2,0]),
- Fix2Long(*mr.matrix[2,1]), Fix2Long(*mr.matrix[2,2]));
-
- // TRACK VOLUME
- trackVol = GetTrackVolume(aTrack);
- if(trackVol == 255)
- printf("Track Volume is 1.0\n");
- else
- printf("Track Volume = %d.%d\n", (signed short)(trackVol >> 8) , (trackVol & 0xFF));
- }
- }
-
-
- // ______________________________________________________________________
- void ShowMovieVideoInfo(Movie theMovie)
- {
- Str255 tmpStr;
- short trackCount, index;
- OSErr anErr = noErr;
-
- DebugAssert(aMovie != NULL);
-
- GetWTitle(FrontWindow(), tmpStr);
- printf("\nVideo Media Information for %s:\n", p2cstr(tmpStr));
-
- // VIDEO FRAMES/SAMPLES
- printf("The movie has %d video frames (samples)\n", QTUCountMediaSamples(theMovie, VideoMediaType));
-
- printf("The duration of the first video sample is %ld\n", QTUGetDurationOfFirstMovieSample(theMovie, VideoMediaType));
-
- // Get the Image Description Structure and present the values.
- trackCount = GetMovieTrackCount(theMovie);
-
- for(index = 1; index <= trackCount; index++)
- {
- Track aTrack = NULL;
- Media aMedia = NULL;
- OSType aMediaType;
-
- aTrack = GetMovieIndTrack(theMovie, index); DebugAssert(aTrack != NULL);
- aMedia = GetTrackMedia(aTrack); DebugAssert(aMedia != NULL);
- anErr = GetMoviesError(); DebugAssert(anErr == noErr);
- if(anErr != noErr)
- {
- printf("Problems with getting trackmedia = %d\n", anErr);
- return;
- }
-
- GetMediaHandlerDescription(aMedia, &aMediaType, 0, 0);
- if(aMediaType == VideoMediaType) // We just want to check the video media samples.
- {
- SampleDescriptionHandle anImageDesc = NULL;
- anImageDesc = (SampleDescriptionHandle)NewHandle(sizeof(SampleDescription));
- DebugAssert(GetMemErr == noErr);
-
- GetMediaSampleDescription(aMedia, 1, anImageDesc);
- anErr = GetMoviesError(); DebugAssert(anErr == noErr);
- MoveHHi((Handle)anImageDesc); HLock((Handle)anImageDesc); // Really would not need to, but printf (don't trust that one
- // due to the MetroWerks Sioux environment).
- if(anErr != noErr)
- {
- DisposeHandle((Handle)anImageDesc);
- continue;
- }
-
- // OK, we have the Image Description, now present the values (see IM:QuickTime, page 3-50 for more
- // information about the ImageDescription structure).
-
- printf("The video track has a pixel depth of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->depth);
-
- printf("The video track has a source image width of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->width);
- printf("The video track has a source image height of %d.\n", (*(ImageDescriptionHandle)anImageDesc)->height);
- printf("The video track has a horizontal resolution of %ld.\n", Fix2Long( (*(ImageDescriptionHandle)anImageDesc)->hRes) );
- printf("The video track has a vertical resolution of %ld.\n", Fix2Long( (*(ImageDescriptionHandle)anImageDesc)->vRes) );
-
- printf("The codec used to compress the video samples: %s\n", p2cstr( (*(ImageDescriptionHandle)anImageDesc)->name) );
- printf("Note that this is the codec for the first video sample, the video samples in the movie might have various codecs used...\n");
- {
- Byte *bp = (Byte *)&(*(ImageDescriptionHandle)anImageDesc)->vendor;
- printf("The video track was compressed by codec provided by '%c%c%c%c'.\n", bp[0], bp[1], bp[2], bp[3]);
- }
- printf("The temporal compression setting is %ld\n", (*(ImageDescriptionHandle)anImageDesc)->temporalQuality);
- printf("The spatial compression setting is %ld\n", (*(ImageDescriptionHandle)anImageDesc)->spatialQuality);
-
-
- printf("The image description structure is %ld bytes in size.\n",
- (*(ImageDescriptionHandle)anImageDesc)->idSize);
-
- DisposeHandle((Handle)anImageDesc);
- }
- }
- }
-
-
- // ______________________________________________________________________
- void ShowMovieSoundInfo(Movie theMovie)
- {
- Str255 tmpStr;
- short trackCount, index;
- OSErr anErr = noErr;
-
- DebugAssert(aMovie != NULL);
-
- GetWTitle(FrontWindow(), tmpStr);
- printf("\nSound Media Information for %s:\n", p2cstr(tmpStr));
-
- #ifdef THIS_WILL_TAKE_LONG
- printf("The movie has %d sound samples (samples)\n", QTUCountMediaSamples(theMovie, SoundMediaType));
- #endif // THIS_WILL_TAKE_LONG
-
- // Get the sound description handle and munch it:
- trackCount = GetMovieTrackCount(theMovie);
-
- for(index = 1; index <= trackCount; index++)
- {
- Track aTrack = NULL;
- Media aMedia = NULL;
- OSType aMediaType;
-
- aTrack = GetMovieIndTrack(theMovie, index); DebugAssert(aTrack != NULL);
- aMedia = GetTrackMedia(aTrack); DebugAssert(aMedia != NULL);
- anErr = GetMoviesError(); DebugAssert(anErr == noErr);
- if(anErr != noErr)
- {
- printf("Problems with getting trackmedia = %d\n", anErr);
- return;
- }
-
- GetMediaHandlerDescription(aMedia, &aMediaType, 0, 0);
- if(aMediaType == SoundMediaType) // We just want to check out the sound description handles.
- {
- SampleDescriptionHandle aDesc = NULL;
- aDesc = (SampleDescriptionHandle)NewHandle(sizeof(SampleDescription));
- DebugAssert(GetMemErr() == noErr);
-
- GetMediaSampleDescription(aMedia, 1, aDesc);
- anErr = GetMoviesError(); DebugAssert(anErr == noErr);
- MoveHHi((Handle)aDesc); HLock((Handle)aDesc); // Really would not need to, but printf (don't trust that one
- // due to the MetroWerks Sioux environment).
- if(anErr != noErr)
- {
- DisposeHandle((Handle)aDesc);
- continue;
- }
- // OK, we have the sound description handle now, present the values
- printf("The sound track rate is %d Hz.\n", (*(SoundDescriptionHandle)aDesc)->sampleRate >> 16);
-
- printf("The sound track size is %d bit.\n", (*(SoundDescriptionHandle)aDesc)->sampleSize);
-
- printf("The sound track has %d channel(s).\n", (*(SoundDescriptionHandle)aDesc)->numChannels);
- {
- Byte *bp = (Byte *)&(*(SoundDescriptionHandle)aDesc)->dataFormat;
- printf("The sound track has the '%c%c%c%c' format.\n", bp[0], bp[1], bp[2], bp[3]);
- }
-
- printf("The sound description structure is %ld bytes in size.\n",
- (*(SoundDescriptionHandle)aDesc)->descSize);
-
- }
- }
- }
-
-